using System;
using System.Collections.Generic;
using System.Text;

namespace SharpMud.Terminal
{
    /// <summary>
    /// A System.IO.TextWriter designed to redirect output to a given IOutputTerminal
    /// </summary>
    public class OutputTerminalWriter : System.IO.TextWriter
    {
        private IOutputTerminal _Terminal;
        private bool _Closed;

        protected OutputTerminalWriter()
        {
            _Closed = true;
        }
        public OutputTerminalWriter(IOutputTerminal terminal)
        {
            _Terminal = terminal;
            _Closed = false;
        }

        public override Encoding Encoding
        {
            get
            {
                return _Terminal.OutputEncoding;
            }
        }

        public override void Close()
        {
            base.Close();
            _Closed = true;
        }

        public override void Write(string value)
        {
            _Terminal.Write(value);
        }
        public override void Write(char value)
        {
            _Terminal.Write(value);
        }
        public override void Write(char[] buffer)
        {
            _Terminal.Write(buffer);
        }
        public override void Write(char[] buffer, int start, int length)
        {
            _Terminal.Write(buffer, start, length);
        }
    }
}
